package com.study.teacher;

public class CalcCommand implements Command{
	private char operator;
	private int operand;
	private Calculator cal;
	public CalcCommand(Calculator cal,char operator,int operand){
		this.cal = cal;
		this.operator = operator;
		this.operand = operand;		
	}
	
	public void execute(){
		this.cal.calc(operator,operand);
	}
	
	public void unExecute(){
		this.cal.calc(undo(operator),operand);
	}
	
	private char undo(char operator){
		char obj=' ';
		switch(operator){
		case '+':obj='-';break;
		case '-':obj='+';break;
		case '*':obj='/';break;
		case '/':obj='*';break;
		}
		return obj;
	}
}
